package com.shen.utils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;


public class SSCUtils {
	static String[] allsscStr = new String[] { "00", "01", "02", "03", "04", "05",
		"06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16",
		"17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27",
		"28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38",
		"39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49",
		"50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60",
		"61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71",
		"72", "73", "74", "75", "76", "77", "78", "79", "80", "81", "82",
		"83", "84", "85", "86", "87", "88", "89", "90", "91", "92", "93",
		"94", "95", "96", "97", "98", "99" };

	static List<String> allssc = new ArrayList<String>(Arrays.asList(allsscStr));
	
	static List<String> toList(String[] ssc){
		return new ArrayList<String>(Arrays.asList(ssc));
	}
	
	static String[] ssc14 = new String[]{
		"83118","65117","02231","86489","46866","56336","45646","28612","95432","84196","59098","87101","73287","29887","80382","74147","98536","05977","23736","01718","83177","47626","41719","89551","72512","52483","49626","63605","57753","17922","50133","15715","79541","47327","81054","89507","73007","56113","71497","17057","35495","71616","56627","76196","18287","55206","51497","69440","15572","93093","94351","63775","86469","62311","73383","20551","95143","91769","57817","14192","50454","29591","95483","41193","17508","91220","69465","61997","46693","52903","61146","28065","85442","27695","25431","60552","67896","15669","40170","73630","48847","31095","91288","87902","45289","43368","87329","76494","03407","31541","77378","60543","55447","70108","82316","36507","20953","78637","62870","86223","70966","18782","20312","86589","25010","12541","51508","69528","70070","44619","54106","74518","14358","86230","41080","26208","92899","66634","46317","90060"
	};
	
	static String[] ssc15 = new String[]{
		"22485","50323","39438","08160","80242","18203","13415","42271","46752","31300","65891","90190","58769","61119","21527","43732","90121","38993","22208","25130","92579","05472","66554","99019","12647","01903","60270","54870","92167","74179","11339","76975","46210","85488","57362","74077","03053","14126","35091","54117","75821","03717","90218","98972","96180","76090","65048","57695","76255","10221","04120","36600","02212","92811","58350","00733","67374","12381","43209","63668","60995","35222","53277","59562","05829","44871","82079","40850","20798","38861","14769","84994","75787","63252","79860","85394","32897","24861","59858","76155","64365","45245","36162","94921","07556","21307","62050","61537","97705","94244","08858","28502","09947","06894","31417","45544","35106","65890","23622","84507","68629","32115","14225","55696","54574","48578","92170","65451","61388","46103","16504","97663","61729","94240","27150","81387","27332","56347","73172","23339"
	};
	
	static String[] ssc16 = new String[]{
		"35937","47967","12346","82685","70194","78180","45585","12024","07570","81514","85852","10768","66582","43669","41790","79110","93143","40822","17282","36186","85627","95358","22702","02577","38865","43066","01833","22836","60384","98249","89096","64715","95671","64217","88490","83001","59818","43395","87889","81277","82352","88213","55893","71632","03047","69183","94882","31595","60576","05363","55097","31891","22029","93499","33973","61172","18327","86591","32549","78143","70875","05019","78555","60883","54155","86539","79463","67861","20618","47254","68496","04517","67972","16096","17464","99552","99451","20469","94966","44009","28405","42282","36301","03838","37371","42359","33179","43346","57085","14031","77151","11430","17747","92965","66116","12642","16139","95054","96962","42256","32715","65994","23498","91562","35006","54127","63715","03547","84113","34176","04433","87364","58249","37476","13197","05154","50109","58059","55042","53639"
	};
	
	
	static String[] ssc17 = new String[] { "98632", "82810", "77783", "02295",
		"32754", "20034", "89347", "17874", "89879", "81545", "42532",
		"78947", "06026", "64647", "23495", "65449", "29843", "30962",
		"09151", "29778", "76755", "80302", "97705", "09414", "99104",
		"21100", "04887", "71765", "54430", "54684", "17830", "25873",
		"70376", "76818", "06665", "29359", "59851", "48069", "29822",
		"88036", "81684", "22174", "57994", "99008", "32973", "07679",
		"52553", "43608", "96695", "23063", "51593", "06272", "70253",
		"83341", "70205", "64138", "45228", "72552", "96707", "91808",
		"65258", "63928", "62121", "58155", "12870", "20614", "43259",
		"09457", "91821", "10854", "39227", "71301", "33514", "72154",
		"75979", "83864", "74395", "19952", "10475", "47463", "04118",
		"17930", "69028", "78601", "57025", "68833", "59751", "97345",
		"44114", "31445", "67390", "87955", "60840", "64836", "64095",
		"83863", "71378", "43290", "11167", "44876", "83066", "78216",
		"40844", "48345", "43292", "09004", "88787", "10305", "80871",
		"46929", "67186", "30339", "44400", "03492", "89788", "87870",
		"07908", "46082", "46305", "26752" };

	public void test1() {
		System.out.println(ssc17.length);
	}
	
	public List<String> getHou2(String[] ssc){
		List<String> hou2list = new ArrayList<String>();
		for(String num : ssc){
			String h2 = num.substring(3, 5);
			hou2list.add(h2);
		}
		return hou2list;
	}
	
	/**
	 * ȥ���ظ�Ԫ�ط���
	 * @param list
	 * @return
	 */
	public static List<String> removeDuplicateWithOrder(List<String> list) {   
		//����Set :Ԫ�ز��ظ�   
		Set<String> set = new HashSet<String>();   
		//����List ��Ų��ظ���Ԫ��   
		List<String> newList = new ArrayList<String>();   
		//�õ�list�ĵ����   
		for (String element : list) {   
			//��� set ����δ����ָ����Ԫ�أ�����Ӵ�Ԫ��,����true    
			//���� set �Ѿ����Ԫ�أ���õ��ò��ı�� set ���� false��    
			if (set.add(element)){
				//���Ԫ��   
				newList.add(element);
			}
		}   
		return newList;   
	}
	
	public static void getCount(List<String> removeDuplicateList){
		//����ȥ���ظ�Ԫ�ص�List ����ÿ��Ԫ�صĸ���   
        for (int i = 0; i < removeDuplicateList.size(); i++) {   
            //���Ԫ��ֵ   
           String value = removeDuplicateList.get(i);   
//            //��value��ֵ��name   
//            String name = value;   
            //�������   
            int count = 0;   
            for (int j = 0; j < allsscStr.length; j++) {   
                //���Ԫ��ֵ�к�ԭ��List�е�ֵ��� count++   
                if (value.equals(allsscStr[j])) {   
                   count++;   
                }   
            }   
           System.out.println("Ԫ��ֵ:" + value + "   ����:" + count);   
        }
	}
	
	
	public static void main(String[] args) {
		SSCUtils nu = new SSCUtils();
		System.out.println("14�ڣ�100�����֣�ȫ��120�ڳ��ֲ�ͬ���ָ��� = ��"+SSCUtils.removeDuplicateWithOrder(nu.getHou2(ssc14)).size());
		System.out.println("15�ڣ�100�����֣�ȫ��120�ڳ��ֲ�ͬ���ָ��� = ��"+SSCUtils.removeDuplicateWithOrder(nu.getHou2(ssc15)).size());
		System.out.println("16�ڣ�100�����֣�ȫ��120�ڳ��ֲ�ͬ���ָ��� = ��"+SSCUtils.removeDuplicateWithOrder(nu.getHou2(ssc16)).size());
		System.out.println("17�ڣ�100�����֣�ȫ��120�ڳ��ֲ�ͬ���ָ��� = ��"+SSCUtils.removeDuplicateWithOrder(nu.getHou2(ssc17)).size());
		
		
//		SSCUtils
		
	//	for (String num : allssc) {
	//		allssc.
	//	}
	}
}